package com.deyuanyun.pic.settings.service.org.impl;

import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.deyuanyun.pic.settings.mapper.org.OrgInfoMapper;
import com.deyuanyun.pic.settings.service.org.OrgService;
import com.github.pagehelper.Page;

@Service
public class OrgServiceImpl implements OrgService {

	@Resource
	OrgInfoMapper orgInfoMapper;

	@Override
	public List<HashMap<String, Object>> findData(String id) {
		List<HashMap<String, Object>> data=orgInfoMapper.findData(null);
		parse(data);
		return data;
	}
	
	public void parse(List<HashMap<String, Object>> data)
	{
		for(HashMap map:data)
		{
			List<HashMap<String, Object>> result=orgInfoMapper.findData((String)map.get("ID"));
			if(result.size()>0){
				parse(result);
				map.put("children", result);
			}
		}
	}

	@Override
	public HashMap<String, Object> findOrg(String orgID) {
		// TODO Auto-generated method stub
		return orgInfoMapper.findOrg(orgID);
	}

}
